#pragma once

#include<iostream>
#include<vector>
#include<string>
#include<fstream>
#include<fcntl.h>

namespace ns_mvccom{
    void StringSplit(std::string& s,std::vector<std::string>& vs,char sep,bool isCompress=true){
        int left=0;
        int right=1;
        while(right<=s.size()){
            if(s.size()==right||(32==s[right])){
                if(!isCompress||(right>left)){
                    vs.push_back(s.substr(left,right-left));
                }
                left=right+1;
            }
            ++right;
        }
    }

        bool Read(std::string filepath,std::string& content,bool iskeep=true){
        std::ifstream in(filepath);
        if(!in.is_open()){
            return false;
        }
        std::string tmp;
        while(std::getline(in,tmp))
        {
            content+=tmp;
            if(iskeep){
                content+="\n";
            }
        }
        in.close();

        return true;
        }

    typedef struct questionList{
        unsigned int id;
        std::string level;
        std::string title;
    }questionList;

    typedef struct questionDetail{
        unsigned int id;
        std::string level;
        std::string title;
        std::string desc;
        std::string precode;
    }questionDetail;

    typedef struct questionTest{
        unsigned int timelimit;
        unsigned int spacelimit;
        std::string testcode;
    }questionTest;
}